• Steven Ponce
  • About
  • Data Visualizations
  • Projects
  • Resume
  • Email

On this page

  • Steps to Create this Graphic
    • 1. Load Packages & Setup
    • 2. Read in the Data
    • 3. Examine the Data
    • 4. Tidy Data
    • 5. Visualization Parameters
    • 6. Plot
    • 7. Save
    • 8. Session Info
    • 9. GitHub Repository
    • 10. References
    • 11. Custom Functions Documentation

Oh My God, Bob!

  • Show All Code
  • Hide All Code

  • View Source

‘My God’ accounts for 56% of 2,420 god-mentions across 16 seasons of Bob’s Burgers

Bob's Burgers
Standalone
Data Visualization
R Programming
2026
A data visualization exploring divine invocations in Bob’s Burgers using transcript data from the bobsburgersR package. The analysis reveals ‘My God’ dominates the lexicon at 56%, with S8E6 ‘Bleakening Pts 1 & 2’ crowned the most devout episode with 24 mentions.
Author

Steven Ponce

Published

January 23, 2026

Figure 1: Data visualization titled ‘Oh My God, Bob!’ analyzing 2,420 god-mentions across 16 seasons of Bob’s Burgers. A treemap shows ‘My God’ dominates at 56%, followed by ‘God’ at 37% and ‘Thank God’ at 5%. A bar chart ranks the most devout episodes, with S8E6 ‘Bleakening Pts 1 & 2’ leading with 24 mentions.

Steps to Create this Graphic

1. Load Packages & Setup

Show code
```{r}
#| label: load
#| warning: false
#| message: false
#| results: "hide"

## 1. LOAD PACKAGES & SETUP ----
suppressPackageStartupMessages({
if (!require("pacman")) install.packages("pacman")
pacman::p_load(
  tidyverse,         # Easily Install and Load the 'Tidyverse'
  ggtext,            # Improved Text Rendering Support for 'ggplot2'
  showtext,          # Using Fonts More Easily in R Graphs
  janitor,           # Simple Tools for Examining and Cleaning Dirty Data
  skimr,             # Compact and Flexible Summaries of Data
  scales,            # Scale Functions for Visualization
  glue,              # Interpreted String Literals
  patchwork,         # The Composer of Plots
  treemapify,        # Draw Treemaps in 'ggplot2'
  bobsburgersR       # Bob's Burgers Datasets for Data Visualization
)  
})

### |- figure size ----
camcorder::gg_record(
  dir    = here::here("temp_plots"),
  device = "png",
  width  = 14,
  height = 9,
  units  = "in",
  dpi    = 320
)

# Source utility functions
suppressMessages(source(here::here("R/utils/fonts.R")))
source(here::here("R/utils/social_icons.R"))
source(here::here("R/utils/image_utils.R"))
source(here::here("R/themes/base_theme.R"))
```

2. Read in the Data

Show code
```{r}
#| label: read
#| include: true
#| eval: true
#| warning: false

transcript_data <- bobsburgersR::transcript_data
```

3. Examine the Data

Show code
```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false

glimpse(transcript_data)
skim_without_charts(transcript_data)
```

4. Tidy Data

Show code
```{r}
#| label: tidy-fixed
#| warning: false

# Filter for "god" mentions
god_mentions <- transcript_data |>
  filter(
    str_detect(raw_text, regex("\\bgod\\b|\\bgods\\b|goddamn", ignore_case = TRUE)),
    !str_detect(raw_text, regex("godfather|godmother|godparent|godchild", ignore_case = TRUE))
  ) |>
  mutate(
    type = if_else(is.na(dialogue), "Sound Effect", "Spoken"),
    dialogue_clean = coalesce(dialogue, raw_text)
  )

# Categorize god mentions
god_categorized <- god_mentions |>
  mutate(
    god_type = case_when(
      str_detect(raw_text, regex("oh my god", ignore_case = TRUE)) ~ "Oh My God",
      str_detect(raw_text, regex("for god'?s sake", ignore_case = TRUE)) ~ "For God's Sake",
      str_detect(raw_text, regex("god damn|goddamn", ignore_case = TRUE)) ~ "Goddamn",
      str_detect(raw_text, regex("thank god", ignore_case = TRUE)) ~ "Thank God",
      str_detect(raw_text, regex("dear god", ignore_case = TRUE)) ~ "Dear God",
      str_detect(raw_text, regex("good god", ignore_case = TRUE)) ~ "Good God",
      str_detect(raw_text, regex("oh god", ignore_case = TRUE)) ~ "Oh God",
      str_detect(raw_text, regex("my god", ignore_case = TRUE)) ~ "My God",
      str_detect(raw_text, regex("\\bgod\\b", ignore_case = TRUE)) ~ "God",
      TRUE ~ "Other"
    )
  )

# Summary stats
total_mentions <- nrow(god_categorized)
total_seasons <- n_distinct(god_categorized$season)

# Lexicon breakdown
god_lexicon <- god_categorized |>
  count(god_type, sort = TRUE) |>
  mutate(pct = n / sum(n))

# Top episodes
top_episodes <- god_categorized |>
  count(season, episode, title, sort = TRUE) |>
  head(10)

# Most devout episodes data
top_eps_plot <- top_episodes |>
  head(6) |>
  mutate(
    ep_label = glue("S{season}E{episode}"),
    title_short = str_trunc(title, 34),
    full_label = glue("{ep_label}:\n{title_short}"),
    full_label = fct_reorder(full_label, n),
    is_top = n == max(n)
  )
```

5. Visualization Parameters

Show code
```{r}
#| label: params
#| include: true
#| warning: false

### |-  plot aesthetics ----
colors <- get_theme_colors(
  palette = list(
    yellow     = "#D4A03C",
    green      = "#94994a",
    red        = "#b85244",
    blue       = "#8db8e2",
    gray_light = "#D3D3D3",
    black      = "#2B2B2B",
    gray       = "#5A5A5A",
    light_gray = "#9A9A9A",
    off_white  = "#FAF9F6"
  )
)

### |- titles and caption ----
title_text <- "Oh My God, Bob!"

subtitle_text <- str_glue(
  "\"My God\" accounts for 56% of 2,420 god-mentions across 16 seasons of Bob's Burgers"
)

caption_text <- create_standalone_caption(                       
  source_text = "{ bobsburgersR } v0.2.0 (transcripts)"
)

### |-  fonts ----
setup_fonts()
fonts <- get_font_families()

### |-  plot theme ----
# Start with base theme
base_theme <- create_base_theme(colors)

# Add weekly-specific theme elements
weekly_theme <- extend_weekly_theme(
  base_theme,
  theme(
    # Text styling
    plot.title = element_text(
      face = "bold", family = fonts$title, size = rel(1.4),        
      color = colors$title, margin = margin(b = 10), hjust = 0
    ),
    plot.subtitle = element_text(
      face = "italic", family = fonts$subtitle, lineheight = 1.2,
      color = colors$subtitle, size = rel(0.85), margin = margin(b = 20), hjust = 0    
    ),
    
    # Grid
    panel.grid.minor = element_blank(),
    panel.grid.major.x = element_blank(),
    panel.grid.major = element_line(color = "gray90", linewidth = 0.25),
    
    # Axes
    axis.title = element_text(size = rel(0.8), color = "gray30"),
    axis.text = element_text(color = "gray30"),
    axis.text.y = element_text(size = rel(0.85)),
    axis.ticks = element_blank(),
    
    # Facets
    strip.background = element_rect(fill = "gray95", color = NA),
    strip.text = element_text(
      face = "bold",
      color = "gray20",
      size = rel(0.9),
      margin = margin(t = 6, b = 4)
    ),
    panel.spacing = unit(1.5, "lines"),
    
    # Legend elements
    legend.position = "plot",
    legend.title = element_text(
      family = fonts$subtitle,
      color = colors$text, size = rel(0.8), face = "bold"
    ),
    legend.text = element_text(
      family = fonts$tsubtitle,
      color = colors$text, size = rel(0.7)
    ),
    legend.margin = margin(t = 15),
    
    # Plot margin
    plot.margin = margin(10, 20, 10, 20),
    
  )
)

# Set theme
theme_set(weekly_theme)
```

6. Plot

Show code
```{r}
#| label: plot
#| warning: false

# P1: KPI 
p1 <- ggplot() +
  # KPI 1: Total mentions
  annotate("text",
    x = 1, y = 1.1, label = comma(total_mentions),
    size = 14, fontface = "bold", family = "title", color = colors$palette$green
  ) +
  annotate("text",
    x = 1, y = 0.7, label = "god-mentions",
    size = 4.5, family = "text", color = colors$palette$gray
  ) +
  # KPI 2: Champion episode
  annotate("text",
    x = 3, y = 1.1, label = "S8E6",
    size = 12, fontface = "bold", family = "title", color = colors$palette$green
  ) +
  annotate("text",
    x = 3, y = 0.7, label = "top episode (24 mentions)",
    size = 4.5, family = "text", color = colors$palette$gray
  ) +
  # KPI 3: Line 1 Club
  annotate("text",
    x = 5, y = 1.1, label = "4",
    size = 14, fontface = "bold", family = "title", color = colors$palette$green
  ) +
  annotate("text",
    x = 5, y = 0.7, label = "episodes open with 'god'",
    size = 4.5, family = "text", color = colors$palette$gray
  ) +
  xlim(0, 6) +
  ylim(0.4, 1.4) +
  theme_void() +
  theme(
    plot.background = element_rect(fill = colors$palette$off_white, color = NA),
    plot.margin = margin(10, 20, 5, 20)
  )

# P2: treemap
# treemap data
treemap_data <- god_lexicon |>
  filter(god_type != "Other") |>
  mutate(
    label_full = paste0(god_type, "\n", percent(pct, accuracy = 1)),
    # Only show label if >= 3%
    label_display = if_else(pct >= 0.03, label_full, ""),
    # Color assignment - gray for small categories
    fill_color = case_when(
      god_type == "My God" ~ colors$palette$green,
      god_type == "God" ~ colors$palette$yellow,
      god_type == "Thank God" ~ colors$palette$red,
      TRUE ~ colors$palette$gray_light
    )
  )

treemap_colors <- setNames(treemap_data$fill_color, treemap_data$god_type)

p2 <- treemap_data |>
  ggplot(aes(area = n, fill = god_type, label = label_display)) +
  geom_treemap(color = "white", size = 2) +
  geom_treemap_text(
    family = "text",
    color = "white",
    place = "centre",
    size = 14,
    fontface = "bold",
    min.size = 4
  ) +
  scale_fill_manual(values = treemap_colors) +
  labs(
    title = "The God Lexicon",
    subtitle = "\"My God\" dominates at 56% of all mentions"
  )

# P3: Most devout episodes
p3 <- top_eps_plot |>
  ggplot(aes(x = n, y = full_label)) +
  geom_col(aes(fill = is_top), width = 0.75, show.legend = FALSE) +
  geom_text(
    aes(
      label = if_else(is_top, glue("{ n } *"), as.character(n)),
      fontface = if_else(is_top, "bold", "plain"),
    ),
    hjust = -0.2,
    size = 3.8,
    family = "text",
    color = colors$palette$gray
  ) +
  scale_fill_manual(values = c("TRUE" = colors$palette$green, "FALSE" = colors$palette$yellow)) +
  scale_x_continuous(expand = expansion(mult = c(0, 0.12))) +
  labs(
    title = "Most Devout Episodes",
    subtitle = "Episodes with the most god-mentions",
    x = "Mentions",
    y = NULL
  )

# Combine: Final Layout
combined_plot <-
  p1 / (p2 | p3) +
  plot_layout(heights = c(0.25, 1))

combined_plot <- combined_plot +
  plot_annotation(
    title = title_text,
    subtitle = subtitle_text,
    caption = caption_text,
  theme = theme(
    plot.title = element_text(
      size = rel(2.14),
      family = fonts$title,
      face = "bold",
      color = colors$title,
      lineheight = 1.15,
      margin = margin(t = 5, b = 5)
    ),
    plot.subtitle = element_text(
      size = rel(1.0),
      family = fonts$subtitle,
      color = colors$subtitle,
      lineheight = 1.5,
      margin = margin(t = 5, b = 15)
    ),
    plot.caption = element_markdown(
      size = rel(0.65),
      family = fonts$subtitle,
      color = colors$caption,
      hjust = 0,
      lineheight = 1.4,
      margin = margin(t = 20, b = 5)
    ),
    plot.margin = margin(12, 18, 10, 18)
  )
)
```

7. Save

Show code
```{r}
#| label: save
#| warning: false

### |-  plot image ----  
save_plot_patchwork(
  plot = combined_plot, 
  type = "standalone", 
  year = 2026,
  width  = 14,
  height = 9,
  )
```

8. Session Info

Expand for Session Info
R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26100)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] here_1.0.1         bobsburgersR_0.2.0 treemapify_2.5.6   patchwork_1.3.0   
 [5] glue_1.8.0         scales_1.3.0       skimr_2.1.5        janitor_2.2.0     
 [9] showtext_0.9-7     showtextdb_3.0     sysfonts_0.8.9     ggtext_0.1.2      
[13] lubridate_1.9.3    forcats_1.0.0      stringr_1.5.1      dplyr_1.1.4       
[17] purrr_1.0.2        readr_2.1.5        tidyr_1.3.1        tibble_3.2.1      
[21] ggplot2_3.5.1      tidyverse_2.0.0    pacman_0.5.1      

loaded via a namespace (and not attached):
 [1] ggfittext_0.10.2   gtable_0.3.6       xfun_0.49          htmlwidgets_1.6.4 
 [5] tzdb_0.5.0         yulab.utils_0.1.8  vctrs_0.6.5        tools_4.4.0       
 [9] generics_0.1.3     curl_6.0.0         gifski_1.32.0-1    fansi_1.0.6       
[13] pkgconfig_2.0.3    ggplotify_0.1.2    lifecycle_1.0.4    compiler_4.4.0    
[17] farver_2.1.2       munsell_0.5.1      repr_1.1.7         codetools_0.2-20  
[21] snakecase_0.11.1   htmltools_0.5.8.1  yaml_2.3.10        pillar_1.9.0      
[25] camcorder_0.1.0    magick_2.8.5       commonmark_1.9.2   tidyselect_1.2.1  
[29] digest_0.6.37      stringi_1.8.4      labeling_0.4.3     rsvg_2.6.1        
[33] rprojroot_2.0.4    fastmap_1.2.0      grid_4.4.0         colorspace_2.1-1  
[37] cli_3.6.4          magrittr_2.0.3     base64enc_0.1-3    utf8_1.2.4        
[41] withr_3.0.2        timechange_0.3.0   rmarkdown_2.29     hms_1.1.3         
[45] evaluate_1.0.1     knitr_1.49         markdown_1.13      gridGraphics_0.5-1
[49] rlang_1.1.6        gridtext_0.1.5     Rcpp_1.0.13-1      xml2_1.3.6        
[53] renv_1.0.3         svglite_2.1.3      rstudioapi_0.17.1  jsonlite_1.8.9    
[57] R6_2.5.1           fs_1.6.5           systemfonts_1.1.0 

9. GitHub Repository

Expand for GitHub Repo

The complete code for this analysis is available in sa_2026-01-23.qmd.

For the full repository, click here.

10. References

Expand for References
  1. Data Source:
    • bobsburgersR R Package v0.2.0: GitHub Repository
    • Transcript Data: Springfield! Springfield!
  2. Bob’s Burgers:
    • Official Show Page: FOX - Bob’s Burgers
    • Wikipedia: Bob’s Burgers Episode List

11. Custom Functions Documentation

📦 Custom Helper Functions

This analysis uses custom functions from my personal module library for efficiency and consistency across projects.

Functions Used:

  • fonts.R: setup_fonts(), get_font_families() - Font management with showtext
  • social_icons.R: create_social_caption() - Generates formatted social media captions
  • image_utils.R: save_plot() - Consistent plot saving with naming conventions
  • base_theme.R: create_base_theme(), extend_weekly_theme(), get_theme_colors() - Custom ggplot2 themes

Why custom functions?
These utilities standardize theming, fonts, and output across all my data visualizations. The core analysis (data tidying and visualization logic) uses only standard tidyverse packages.

Source Code:
View all custom functions → GitHub: R/utils

Back to top

Citation

BibTeX citation:
@online{ponce2026,
  author = {Ponce, Steven},
  title = {Oh {My} {God,} {Bob!}},
  date = {2026-01-23},
  url = {https://stevenponce.netlify.app/projects/standalone_visualizations/sa_2026-01-23.html},
  langid = {en}
}
For attribution, please cite this work as:
Ponce, Steven. 2026. “Oh My God, Bob!” January 23, 2026. https://stevenponce.netlify.app/projects/standalone_visualizations/sa_2026-01-23.html.
Source Code
---
title: "Oh My God, Bob!"
subtitle: "'My God' accounts for 56% of 2,420 god-mentions across 16 seasons of Bob's Burgers"
description: "A data visualization exploring divine invocations in Bob's Burgers using transcript data from the bobsburgersR package. The analysis reveals 'My God' dominates the lexicon at 56%, with S8E6 'Bleakening Pts 1 & 2' crowned the most devout episode with 24 mentions."
date: "2026-01-23"
author:
  - name: "Steven Ponce"
    url: "https://stevenponce.netlify.app"
citation:    
    url: "https://stevenponce.netlify.app/projects/standalone_visualizations/sa_2026-01-23.html"
categories: ["Bob's Burgers", "Standalone", "Data Visualization", "R Programming", "2026"]
tags: [
  "bobsburgersR",
  "ggplot2",
  "treemapify",
  "patchwork",
  "text analysis",
  "TV transcripts",
  "animated series",
  "pop culture data",
  "treemap",
  "bar chart"
]
image: "thumbnails/sa_2026-01-23.png"
format:
  html:
    toc: true
    toc-depth: 5
    code-link: true
    code-fold: true
    code-tools: true
    code-summary: "Show code"
    self-contained: true
    theme: 
      light: [flatly, assets/styling/custom_styles.scss]
      dark: [darkly, assets/styling/custom_styles_dark.scss]
editor_options: 
  chunk_output_type: inline
execute: 
  freeze: true                                    
  cache: true                                       
  error: false
  message: false
  warning: false
  eval: true
---

![Data visualization titled 'Oh My God, Bob!' analyzing 2,420 god-mentions across 16 seasons of Bob's Burgers. A treemap shows 'My God' dominates at 56%, followed by 'God' at 37% and 'Thank God' at 5%. A bar chart ranks the most devout episodes, with S8E6 'Bleakening Pts 1 & 2' leading with 24 mentions.](sa_2026-01-23){#fig-1}

### [**Steps to Create this Graphic**]{.mark}

#### [1. Load Packages & Setup]{.smallcaps}

```{r}
#| label: load
#| warning: false
#| message: false      
#| results: "hide" 

## 1. LOAD PACKAGES & SETUP ----
suppressPackageStartupMessages({
if (!require("pacman")) install.packages("pacman")
pacman::p_load(
  tidyverse,         # Easily Install and Load the 'Tidyverse'
  ggtext,            # Improved Text Rendering Support for 'ggplot2'
  showtext,          # Using Fonts More Easily in R Graphs
  janitor,           # Simple Tools for Examining and Cleaning Dirty Data
  skimr,             # Compact and Flexible Summaries of Data
  scales,            # Scale Functions for Visualization
  glue,              # Interpreted String Literals
  patchwork,         # The Composer of Plots
  treemapify,        # Draw Treemaps in 'ggplot2'
  bobsburgersR       # Bob's Burgers Datasets for Data Visualization
)  
})

### |- figure size ----
camcorder::gg_record(
  dir    = here::here("temp_plots"),
  device = "png",
  width  = 14,
  height = 9,
  units  = "in",
  dpi    = 320
)

# Source utility functions
suppressMessages(source(here::here("R/utils/fonts.R")))
source(here::here("R/utils/social_icons.R"))
source(here::here("R/utils/image_utils.R"))
source(here::here("R/themes/base_theme.R"))
```

#### [2. Read in the Data]{.smallcaps}

```{r}
#| label: read
#| include: true
#| eval: true
#| warning: false

transcript_data <- bobsburgersR::transcript_data
```

#### [3. Examine the Data]{.smallcaps}

```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false

glimpse(transcript_data)
skim_without_charts(transcript_data)
```

#### [4. Tidy Data]{.smallcaps}

```{r}
#| label: tidy-fixed
#| warning: false

# Filter for "god" mentions
god_mentions <- transcript_data |>
  filter(
    str_detect(raw_text, regex("\\bgod\\b|\\bgods\\b|goddamn", ignore_case = TRUE)),
    !str_detect(raw_text, regex("godfather|godmother|godparent|godchild", ignore_case = TRUE))
  ) |>
  mutate(
    type = if_else(is.na(dialogue), "Sound Effect", "Spoken"),
    dialogue_clean = coalesce(dialogue, raw_text)
  )

# Categorize god mentions
god_categorized <- god_mentions |>
  mutate(
    god_type = case_when(
      str_detect(raw_text, regex("oh my god", ignore_case = TRUE)) ~ "Oh My God",
      str_detect(raw_text, regex("for god'?s sake", ignore_case = TRUE)) ~ "For God's Sake",
      str_detect(raw_text, regex("god damn|goddamn", ignore_case = TRUE)) ~ "Goddamn",
      str_detect(raw_text, regex("thank god", ignore_case = TRUE)) ~ "Thank God",
      str_detect(raw_text, regex("dear god", ignore_case = TRUE)) ~ "Dear God",
      str_detect(raw_text, regex("good god", ignore_case = TRUE)) ~ "Good God",
      str_detect(raw_text, regex("oh god", ignore_case = TRUE)) ~ "Oh God",
      str_detect(raw_text, regex("my god", ignore_case = TRUE)) ~ "My God",
      str_detect(raw_text, regex("\\bgod\\b", ignore_case = TRUE)) ~ "God",
      TRUE ~ "Other"
    )
  )

# Summary stats
total_mentions <- nrow(god_categorized)
total_seasons <- n_distinct(god_categorized$season)

# Lexicon breakdown
god_lexicon <- god_categorized |>
  count(god_type, sort = TRUE) |>
  mutate(pct = n / sum(n))

# Top episodes
top_episodes <- god_categorized |>
  count(season, episode, title, sort = TRUE) |>
  head(10)

# Most devout episodes data
top_eps_plot <- top_episodes |>
  head(6) |>
  mutate(
    ep_label = glue("S{season}E{episode}"),
    title_short = str_trunc(title, 34),
    full_label = glue("{ep_label}:\n{title_short}"),
    full_label = fct_reorder(full_label, n),
    is_top = n == max(n)
  )
```

#### [5. Visualization Parameters]{.smallcaps}

```{r}
#| label: params
#| include: true
#| warning: false

### |-  plot aesthetics ----
colors <- get_theme_colors(
  palette = list(
    yellow     = "#D4A03C",
    green      = "#94994a",
    red        = "#b85244",
    blue       = "#8db8e2",
    gray_light = "#D3D3D3",
    black      = "#2B2B2B",
    gray       = "#5A5A5A",
    light_gray = "#9A9A9A",
    off_white  = "#FAF9F6"
  )
)

### |- titles and caption ----
title_text <- "Oh My God, Bob!"

subtitle_text <- str_glue(
  "\"My God\" accounts for 56% of 2,420 god-mentions across 16 seasons of Bob's Burgers"
)

caption_text <- create_standalone_caption(                       
  source_text = "{ bobsburgersR } v0.2.0 (transcripts)"
)

### |-  fonts ----
setup_fonts()
fonts <- get_font_families()

### |-  plot theme ----
# Start with base theme
base_theme <- create_base_theme(colors)

# Add weekly-specific theme elements
weekly_theme <- extend_weekly_theme(
  base_theme,
  theme(
    # Text styling
    plot.title = element_text(
      face = "bold", family = fonts$title, size = rel(1.4),        
      color = colors$title, margin = margin(b = 10), hjust = 0
    ),
    plot.subtitle = element_text(
      face = "italic", family = fonts$subtitle, lineheight = 1.2,
      color = colors$subtitle, size = rel(0.85), margin = margin(b = 20), hjust = 0    
    ),
    
    # Grid
    panel.grid.minor = element_blank(),
    panel.grid.major.x = element_blank(),
    panel.grid.major = element_line(color = "gray90", linewidth = 0.25),
    
    # Axes
    axis.title = element_text(size = rel(0.8), color = "gray30"),
    axis.text = element_text(color = "gray30"),
    axis.text.y = element_text(size = rel(0.85)),
    axis.ticks = element_blank(),
    
    # Facets
    strip.background = element_rect(fill = "gray95", color = NA),
    strip.text = element_text(
      face = "bold",
      color = "gray20",
      size = rel(0.9),
      margin = margin(t = 6, b = 4)
    ),
    panel.spacing = unit(1.5, "lines"),
    
    # Legend elements
    legend.position = "plot",
    legend.title = element_text(
      family = fonts$subtitle,
      color = colors$text, size = rel(0.8), face = "bold"
    ),
    legend.text = element_text(
      family = fonts$tsubtitle,
      color = colors$text, size = rel(0.7)
    ),
    legend.margin = margin(t = 15),
    
    # Plot margin
    plot.margin = margin(10, 20, 10, 20),
    
  )
)

# Set theme
theme_set(weekly_theme)
```

#### [6. Plot]{.smallcaps}

```{r}
#| label: plot
#| warning: false

# P1: KPI 
p1 <- ggplot() +
  # KPI 1: Total mentions
  annotate("text",
    x = 1, y = 1.1, label = comma(total_mentions),
    size = 14, fontface = "bold", family = "title", color = colors$palette$green
  ) +
  annotate("text",
    x = 1, y = 0.7, label = "god-mentions",
    size = 4.5, family = "text", color = colors$palette$gray
  ) +
  # KPI 2: Champion episode
  annotate("text",
    x = 3, y = 1.1, label = "S8E6",
    size = 12, fontface = "bold", family = "title", color = colors$palette$green
  ) +
  annotate("text",
    x = 3, y = 0.7, label = "top episode (24 mentions)",
    size = 4.5, family = "text", color = colors$palette$gray
  ) +
  # KPI 3: Line 1 Club
  annotate("text",
    x = 5, y = 1.1, label = "4",
    size = 14, fontface = "bold", family = "title", color = colors$palette$green
  ) +
  annotate("text",
    x = 5, y = 0.7, label = "episodes open with 'god'",
    size = 4.5, family = "text", color = colors$palette$gray
  ) +
  xlim(0, 6) +
  ylim(0.4, 1.4) +
  theme_void() +
  theme(
    plot.background = element_rect(fill = colors$palette$off_white, color = NA),
    plot.margin = margin(10, 20, 5, 20)
  )

# P2: treemap
# treemap data
treemap_data <- god_lexicon |>
  filter(god_type != "Other") |>
  mutate(
    label_full = paste0(god_type, "\n", percent(pct, accuracy = 1)),
    # Only show label if >= 3%
    label_display = if_else(pct >= 0.03, label_full, ""),
    # Color assignment - gray for small categories
    fill_color = case_when(
      god_type == "My God" ~ colors$palette$green,
      god_type == "God" ~ colors$palette$yellow,
      god_type == "Thank God" ~ colors$palette$red,
      TRUE ~ colors$palette$gray_light
    )
  )

treemap_colors <- setNames(treemap_data$fill_color, treemap_data$god_type)

p2 <- treemap_data |>
  ggplot(aes(area = n, fill = god_type, label = label_display)) +
  geom_treemap(color = "white", size = 2) +
  geom_treemap_text(
    family = "text",
    color = "white",
    place = "centre",
    size = 14,
    fontface = "bold",
    min.size = 4
  ) +
  scale_fill_manual(values = treemap_colors) +
  labs(
    title = "The God Lexicon",
    subtitle = "\"My God\" dominates at 56% of all mentions"
  )

# P3: Most devout episodes
p3 <- top_eps_plot |>
  ggplot(aes(x = n, y = full_label)) +
  geom_col(aes(fill = is_top), width = 0.75, show.legend = FALSE) +
  geom_text(
    aes(
      label = if_else(is_top, glue("{ n } *"), as.character(n)),
      fontface = if_else(is_top, "bold", "plain"),
    ),
    hjust = -0.2,
    size = 3.8,
    family = "text",
    color = colors$palette$gray
  ) +
  scale_fill_manual(values = c("TRUE" = colors$palette$green, "FALSE" = colors$palette$yellow)) +
  scale_x_continuous(expand = expansion(mult = c(0, 0.12))) +
  labs(
    title = "Most Devout Episodes",
    subtitle = "Episodes with the most god-mentions",
    x = "Mentions",
    y = NULL
  )

# Combine: Final Layout
combined_plot <-
  p1 / (p2 | p3) +
  plot_layout(heights = c(0.25, 1))

combined_plot <- combined_plot +
  plot_annotation(
    title = title_text,
    subtitle = subtitle_text,
    caption = caption_text,
  theme = theme(
    plot.title = element_text(
      size = rel(2.14),
      family = fonts$title,
      face = "bold",
      color = colors$title,
      lineheight = 1.15,
      margin = margin(t = 5, b = 5)
    ),
    plot.subtitle = element_text(
      size = rel(1.0),
      family = fonts$subtitle,
      color = colors$subtitle,
      lineheight = 1.5,
      margin = margin(t = 5, b = 15)
    ),
    plot.caption = element_markdown(
      size = rel(0.65),
      family = fonts$subtitle,
      color = colors$caption,
      hjust = 0,
      lineheight = 1.4,
      margin = margin(t = 20, b = 5)
    ),
    plot.margin = margin(12, 18, 10, 18)
  )
)
```

#### [7. Save]{.smallcaps}

```{r}
#| label: save
#| warning: false

### |-  plot image ----  
save_plot_patchwork(
  plot = combined_plot, 
  type = "standalone", 
  year = 2026,
  width  = 14,
  height = 9,
  )
```

#### [8. Session Info]{.smallcaps}

::: {.callout-tip collapse="true"}
##### Expand for Session Info

```{r, echo = FALSE}
#| eval: true
#| warning: false

sessionInfo()
```
:::

#### [9. GitHub Repository]{.smallcaps}

::: {.callout-tip collapse="true"}
##### Expand for GitHub Repo

The complete code for this analysis is available in [`sa_2026-01-23.qmd`](https://github.com/poncest/personal-website/blob/master/projects/standalone_visualizations/sa_2026-01-23.qmd).

For the full repository, [click here](https://github.com/poncest/personal-website/).
:::

#### [10. References]{.smallcaps}

::: {.callout-tip collapse="true"}
##### Expand for References
1.  **Data Source:**
    -   bobsburgersR R Package v0.2.0: [GitHub Repository](https://github.com/poncest/bobsburgersR)
    -   Transcript Data: [Springfield! Springfield!](https://www.springfieldspringfield.co.uk/episode_scripts.php?tv-show=bobs-burgers)
2.  **Bob's Burgers:**
    -   Official Show Page: [FOX - Bob's Burgers](https://www.fox.com/bobs-burgers/)
    -   Wikipedia: [Bob's Burgers Episode List](https://en.wikipedia.org/wiki/List_of_Bob%27s_Burgers_episodes)
:::


#### [11. Custom Functions Documentation]{.smallcaps}

::: {.callout-note collapse="true"}
##### 📦 Custom Helper Functions

This analysis uses custom functions from my personal module library for efficiency and consistency across projects.

**Functions Used:**

-   **`fonts.R`**: `setup_fonts()`, `get_font_families()` - Font management with showtext
-   **`social_icons.R`**: `create_social_caption()` - Generates formatted social media captions
-   **`image_utils.R`**: `save_plot()` - Consistent plot saving with naming conventions
-   **`base_theme.R`**: `create_base_theme()`, `extend_weekly_theme()`, `get_theme_colors()` - Custom ggplot2 themes

**Why custom functions?**\
These utilities standardize theming, fonts, and output across all my data visualizations. The core analysis (data tidying and visualization logic) uses only standard tidyverse packages.

**Source Code:**\
View all custom functions → [GitHub: R/utils](https://github.com/poncest/personal-website/tree/master/R)
:::

© 2024 Steven Ponce

Source Issues